// 定位记录详情页面

<template>
    <f7-page>
        <f7-navbar>
            <f7-nav-left>
                <f7-link back
                         icon-material="arrow_back"></f7-link>
            </f7-nav-left>
            <f7-nav-title>定位记录详情</f7-nav-title>
            <f7-nav-right>
                <f7-icon f7="house"
                         @click.native="fnToHome()"></f7-icon>
            </f7-nav-right>
        </f7-navbar>

        <van-notice-bar style="margin-bottom: 15px;"
                        background="#fff"
                        color="#345">
            <img class="engineeName-icon"
                 src="@/assets/img/sign/engineeName.png"
                 alt="">
            <span>{{controlData.engineeName}}</span>
        </van-notice-bar>

        <div class="newest fff">
            <img class="newPonit-icon"
                 src="@/assets/img/sign/newPonit.png"
                 alt="">
            <span>{{models.model.engineePosition}}</span>
        </div>

        <van-cell-group>
            <van-cell title="登记人"
                      :value="models.model.createUserName">
            </van-cell>
            <van-cell title="登记单位"
                      :value="models.model.createOrgName">
            </van-cell>
            <van-cell title="登记日期"
                      :value="models.model.createTime">
            </van-cell>
        </van-cell-group>

        <van-cell-group v-if="pageAction == 'view'">
            <van-cell title="审核人"
                      :value="models.model.createTime">
            </van-cell>
            <van-cell title="审核结果"
                      :value="models.model.status == 2 ? '通过' : '不通过'">
            </van-cell>
            <van-cell title="审核意见"
                      :value="opinion">
            </van-cell>
            <van-cell title="审核单位"
                      :value="models.model.auditOrgName">
            </van-cell>
            <van-cell title="审核日期"
                      :value="models.model.auditTime">
            </van-cell>
        </van-cell-group>

        <template v-if="pageAction != 'view'">
            <f7-toolbar position="bottom"
                        no-shadow
                        class="fff">
                <f7-button fill
                           class="submit-btn red"
                           @click="fnSubmit(3)">不通过</f7-button>
                <f7-button fill
                           class="submit-btn"
                           @click="fnSubmit(2)">通过</f7-button>
            </f7-toolbar>
        </template>
        <!-- 审核意见 -->
        <v-popup-opinion v-model="showoPinion"
                         :selectUser="selectUser"
                         @save="emitSave">
        </v-popup-opinion>
        <!-- 审核意见 end -->
    </f7-page>
</template>

<script>
import controller from "@/libs/framework/workflowController"

export default class instance extends controller {
    onInit () {
        this.urls = {
            model: "/project/position/getWorkflowViewModel"
        }
    }
    mixin () {
        return {
            created () {
                console.log(this.pageAction)
            },
            data () {
                return {
                    controlData: {},
                    models: {
                        model: {}
                    },
                    selectUser: {
                        selectComment: null,
                        comment: null,
                        comments: [],
                        tran: [],
                        activity: "",
                        users: [],
                    },
                    // pageAction: ''
                    // 审核意见的显示
                    showoPinion: false
                }
            },
            methods: {
                fnSubmit (status) {
                    this.models.model.status = status
                    this.showoPinion = true
                },
                // 提交
                emitSave () {
                    this.send()
                }
            },
            computed: {
                opinion () {
                    if (this.controlData.workflow && this.controlData.workflow.history && this.controlData.workflow.history.length > 0) {
                        let target = this.controlData.workflow.history.findLast(item => item.taskCode == 'usertask2')

                        if (target) {
                            return target.opinionText
                        } else {
                            return ''
                        }
                    } else {
                        return ''
                    }
                }
            }
        }
    }
}
</script>

<style lang="less" scoped>
.newest {
    padding: 10px;
    display: flex;
    align-items: center;
    font-size: 16px;
}

.van-cell-group {
    margin-top: 10px;
}

.engineeName-icon {
    width: 26px;
    vertical-align: middle;
    margin-right: 10px;
}
.newPonit-icon {
    width: 50px;
    margin-right: 10px;
}
</style>
